package config

import (
	"database/sql"
)

/*
假PG线路配置列表
*/

type FakeGameRouteItem struct {
	PlatformId string  `db:"platform_id" `
	status     int     `db:"status" `
	FeeRate    float64 `db:"fee" `
	Priority   int     `db:"priority" `
	RouteName  string  `db:"name" `
	Test       int     `db:"test" `
	GameType   string  `db:"game" `
}

type CsFakeGameRouteInfo struct{}

var CfgFakeGameRouteList []FakeGameRouteItem

func FakeGameRouteRemoveAllCfg() {
	CfgFakeGameRouteList = []FakeGameRouteItem{}
}

func FakeGameRouteCfgSetRow(rows *sql.Rows) {
	var tVal FakeGameRouteItem
	var err error
	err = rows.Scan(&tVal.PlatformId, &tVal.status, &tVal.FeeRate, &tVal.Priority, &tVal.RouteName, &tVal.GameType, &tVal.Test)
	if err == nil {
		CfgFakeGameRouteList = append(CfgFakeGameRouteList, tVal)
	}
}

func FakeGameRouteName(platformId string) string {
	for _, value := range CfgFakeGameRouteList {
		if value.PlatformId == platformId {
			return value.RouteName
		}
	}

	return ""
}

func GetFakeGameAllRoute(GameType string) []FakeGameRouteItem {

	var GameAllRouteList []FakeGameRouteItem
	for _, value := range CfgFakeGameRouteList {
		if value.GameType == GameType {
			GameAllRouteList = append(GameAllRouteList, value)
		}
	}
	return GameAllRouteList
}
